<ui:composition template="/WEB-INF/template/padrao.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="title">Gerencia de Permissões</ui:define>
	<ui:define name="corpo">

		<h:form id="form">

			<p:outputLabel
				value="Username: #{configuraUserMB.selectedUser.username}"></p:outputLabel>

			<p:dataTable value="#{configuraUserMB.selectedUser.autorizacoes}" var="a" border="1" cellpadding="10">
				<p:column headerText="Autorizações Atuais do Usuário">
					<h:outputText value="#{a.nmAutorizacao}" />
				</p:column>
			</p:dataTable>

			<p:dataTable id="radioDT" value="#{autorizacaoMB.aut}" var="aut" border="1" cellpadding="10" selectionMode="multiple"
				rowKey="#{aut.autorizacao}"	selection="#{autorizacaoMB.selectedListAut}">
				<p:column selectionMode="single" style="width:16px;text-align:center" />
				<p:column headerText="Autorizações Atuais do Sistema">
					<h:outputText value="#{aut.nmAutorizacao}" />
				</p:column>

				<f:facet name="footer">
					<p:commandButton process="radioDT" update=":form:autorizacaoDetail"	icon="ui-icon-search" value="Conceder Permissões" oncomplete="PF('autorizacoes').show()" />
				</f:facet>
			</p:dataTable>

			<p:dialog header="Permissões: #{configuraUserMB.selectedUser.username}" widgetVar="autorizacoes" modal="true" showEffect="fade" hideEffect="fade" resizable="false" width="200">
				<p:outputPanel id="autorizacaoDetail" style="text-align:center;">
					<ui:repeat value="#{autorizacaoMB.selectedListAut}" var="aut">
						<h:outputText value="#{aut.autorizacao}" style="display:block" />
					</ui:repeat>
				</p:outputPanel>
				
				<p:commandButton value="Confirmar" actionListener="#{autorizacaoMB.concedePermissao}"/>
			</p:dialog>
		</h:form>
	</ui:define>
</ui:composition>